<%= form_for @changeset, @action, [class: "ui form", multipart: true], fn f -> %>
  <div class="two fields">
    <div class="field required <%= AdminHelpers.error_class(f, :name) %>">
      <%= label(f, :name, "Name") %>
      <%= text_input(f, :name, placeholder: "Wired") %>
    </div>

    <div class="field required <%= AdminHelpers.error_class(f, :slug) %>">
      <%= label(f, :slug, "Slug") %>
      <%= text_input(f, :slug, placeholder: "wired") %>
    </div>
  </div>

  <div class="two fields">
    <div class="field required <%= AdminHelpers.error_class(f, :website) %>">
      <%= label(f, :website, "Website") %>
      <%= text_input(f, :website, placeholder: "https://wired.com") %>
    </div>

    <div class="field <%= AdminHelpers.error_class(f, :twitter) %>">
      <%= label(f, :twitter_handle, "Twitter Handle") %>
      <%= text_input(f, :twitter_handle, placeholder: "wired", mask: "slug") %>
    </div>
  </div>

  <div class="field <%= AdminHelpers.error_class(f, :regex) %>">
    <label for="regex">
      Regex
      <%= AdminHelpers.help_icon("This is used to auto-assign source for a given URL") %>
    </label>
    <%= text_input(f, :regex, placeholder: "wired.com|twitter.com/wired") %>
  </div>

  <div class="field <%= AdminHelpers.error_class(f, :description) %>">
    <label for="description">
      Description
      <%= AdminHelpers.help_icon("140 characters or less.") %>
    </label>
    <%= textarea(f, :description, placeholder: "WIRED is where tomorrow is realized. It is the essential source of information and ideas that make sense of a world in constant transformation.", rows: 2) %>
    <%= AdminHelpers.error_message(f, :description) %>
  </div>


  <div class="field <%= AdminHelpers.error_class(f, :feed) %>">
    <label for="feed">
      RSS Feed
      <%= AdminHelpers.help_icon("Maybe we'll use these to easily draft news items?") %>
    </label>
    <%= text_input(f, :feed, placeholder: "https://www.wired.com/feed/rss") %>
  </div>

  <div class="two fields">
    <div class="fourteen wide field">
      <label for="icon">
        Icon
        <%= AdminHelpers.help_icon("Ideal size is 600px by 600px") %>
        <%= AdminHelpers.file_toggle_buttons() %>
      </label>
      <%= file_input(f, :icon) %>
      <%= AdminHelpers.error_message(f, :icon) %>
    </div>

    <div class="two wide field">
      <img src="<%= ChangelogWeb.NewsSourceView.icon_url(f.data, :small) %>" height=66>
    </div>
  </div>

  <div class="field <%= AdminHelpers.error_class(f, :publication) %>">
    <div class="ui toggle checkbox">
      <%= checkbox(f, :publication, class: "hidden") %>
      <label>Publication <%= AdminHelpers.help_icon("Publication icons show in the feed. Platforms don't") %></label>
    </div>
  </div>

  <div class="ui hidden divider"></div>
  <div class="ui equal width stackable grid">
  <%= if !AdminHelpers.is_persisted(f.data) do %>
    <div class="column"><%= AdminHelpers.submit_button(:primary, "Create") %></div>
    <div class="column"><%= AdminHelpers.submit_button(:secondary, "Create and Close", AdminHelpers.next_param(@conn, Routes.admin_news_source_path(@conn, :index))) %></div>
  <% else %>
    <div class="column"><%= AdminHelpers.submit_button(:primary, "Save", SharedHelpers.current_path(@conn)) %></div>
    <div class="column"><%= AdminHelpers.submit_button(:secondary, "Save and Close", AdminHelpers.next_param(@conn)) %></div>
  <% end %>
    <div class="column"></div>
  </div>
<% end %>
